package shuixian.jing.discuz.utility;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class MyHttpClient {
	private static HttpClient mHttpClient = new DefaultHttpClient();

	public static HttpClient getInstance() {
		return mHttpClient;
	}

	public static String executeGet(String api) {
		String response = null  ;
		try {
			// 创建一个GET请求

			HttpGet request = new HttpGet(
					MySiteConfig.web_rul
							+ api);

			// 发送GET请求，并将响应内容转换成字符串
			BasicResponseHandler bHandler = new BasicResponseHandler();

			response = mHttpClient.execute(request, bHandler);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return response;
	}

}
